package com.factory;

import com.service.Impl.BallService;

import java.lang.reflect.Proxy;

public class BallJdkFactory {
    /**
     * 工厂方法
     * @param ball 需要被代理的目标对象
     * @param <T>
     * @return 返回生成好的代理对象
     */
    public static <T> T create(Object ball){
        BallService service = new BallService();
        service.setBall(ball);
        return (T) Proxy.newProxyInstance(ball.getClass().getClassLoader(),ball.getClass().getInterfaces(),service);
    }
}
